package com.wdbyte.list_to_map;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @description: 判断两个List 是否包含，需要重写Dog的equals方法
 * @program: jdk-new-features
 * @author: gangzhenga
 * @create: 2021/12/10 15:59
 **/


public class Test {

    public static void main(String[] args) {
        Dog dog1 = new Dog();
        dog1.setAge(1);
        dog1.setName("我是dog1");

        Dog dog2 = new Dog();
        dog2.setAge(2);
        dog2.setName("我是dog2");

        Dog dog3 = new Dog();
        dog3.setAge(3);
        dog3.setName("我是dog3");

        Dog dog4 = new Dog();
        dog4.setAge(1);
        dog4.setName("我是dog4");

        List<Dog> list1 = new ArrayList<>();
        list1.add(dog1);
        list1.add(dog2);

        List<Dog> list2 = new ArrayList<>();
        list2.add(dog4);


        AtomicBoolean flag = new AtomicBoolean(false);
        list2.forEach(o -> {
            if(list1.contains(o)){
                flag.set(true);
                return;
            }
        });
    }
}
